import React, { Component } from 'react'
import ReactDOM from 'react-dom'
export default class App extends Component {
  constructor(props){
    super(props)
    this.el=document.createElement("div")
  }

  componentDidMount(){
    document.body.appendChild(this.el)
  }
  state={
    show:false
  }
  handleClick=()=>{
    this.setState({
      show:!this.state.show
    })
   
  }
  
  render() {
    return (
      <div>
        <button onClick={this.handleClick}>显示弹窗</button>
        {
          this.state.show&&ReactDOM.createPortal(<h1>123</h1>,document.body)
        }
      </div>
    )
  }
}
